<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.min.js"></script>

    <title>Document</title>
</head>
<body>
    <div id="app">
        <znn-div :arr='arr'>
            <!-- 数组属性不同时，在此更改 -->
            <template v-slot:data = "res">
                {{res.scope.id}}
            </template>
        </znn-div>
    </div>
</body>

<script>
    new Vue({
        el:"#app",
        components: {
            'znn-div': {
                template: `
                    <div>
                        <div v-for="item in arr">
                            // name是具名插槽，可以不写
                            <slot name="data" :scope="item"></slot>
                        </div>
                    </div>
                `,
                props:['arr'],
                data() {
                    return {
                        
                    }
                }
            }
        },
        data() {
            return {
                // arr: [
                //     {
                //         id:1,
                //         name:'tom'
                //     },
                //     {
                //         id:2,
                //         name:'jerry'
                //     },
                //     {
                //         id:3,
                //         name:'jack'
                //     }
                // ],
                arr:[{id:1,title:"tom"},{id:2,title:"terry"}]
            }
        }
    })
    

</script>
</html>